package com.hubu.mapper;
import com.hubu.pojo.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface teacherUserMapper {
    @Select("SELECT 教师账号 AS username, 教师密码 AS password " +
            "FROM 教师账号表 " +
            "WHERE 教师账号 = #{username} AND 教师密码 = #{password}")
    teacherUser select(@Param("username") String username, @Param("password") String password);

    @Select("select 教师号 AS id,教师姓名 AS name,教师性别 AS gender,教师年龄 AS age,职称 AS office,电话 AS phone " +
            "from 教师表" +
            " where 教师号=#{id}")
    teacher_Information selectTeacherById(String id);
//    String course_id;    //课程号
//    String course_name;  //课程名称
//    String hour;         //学时
//    String teacher_id; //教师号
//    String method;  //考核方式
//    float credits;  //学分

    @Select("SELECT 教师号 AS teacher_id, 考核方式 AS method, 课程号 AS course_id, 学时 AS hour, 课程名称 AS course_name, 学分 AS credits " +
            "FROM 课程表 " +
            "WHERE 教师号 =#{id}")
    List<course_Information> selectTCourseByTeacherId(String id);



    //这里默认一位教师交一门课，不然使用cid tid一起查询

    @Select("SELECT g.学号 AS id, c.课程名称 AS course_name, g.课程号 AS course_id, g.学期 AS term, g.教师号 AS teacher_id, s.姓名 AS student_name, g.成绩 AS grade, c.学分 AS credits" +
            "   FROM 成绩报告表 g" +
            "   JOIN 课程表 c ON g.课程号 = c.课程号" +
            "    JOIN 学生表 s ON g.学号 = s.学号 "+
            "WHERE g.教师号 =#{tid}")
    List<student_single_grade> selectTGradeByTeacherId(String tid);
    @Update("update 成绩报告表 set 成绩=#{nGrade} " +
            "where 学号=#{sid} and 课程号=#{courseId}")
    void updateByStudentIdAndCourseId(@Param("sid") String sid, @Param("courseId") String course_id, @Param("nGrade") Integer nGrade);

}